<?php

namespace App\Models\System;

use Illuminate\Database\Eloquent\Model;
use App\Http\Controllers\PCHController;
use Illuminate\Support\Facades\Redis;


class SystemSettingModel extends Model
{
    public $table = 'live_system_setting';
    public $timestamps = false;
    public static function getSystemSetting()
    {
        $key                        = PCHController::getAllSystemSettingString();
        $data                       = Redis::get($key);
        $data                       = json_decode($data,true);
        if (empty($data)){
            $systemSetting          = SystemSettingModel::query()->get()->toArray();
            $data['SystemSetting']  = [];
            foreach ($systemSetting as $key=>$value){
                $data['SystemSetting'][$value['key']] = $value['value'];
            }
            $data['boot']           = BootModel::getBootImgSetting(0);
            $data['guide']          = BootModel::getBootImgSetting(1);
            $key                    = PCHController::getAllSystemSettingString();
            Redis::setex($key,60,json_encode($data));
        }
        return $data;
    }
}
